package com.classtimer.controller;

import com.classtimer.Model.StudentInfo;
import com.jfinal.core.Controller;

public class RegisterController extends Controller{
	
	
	public void index() {
		render("register.html");
	}
	
	public void register() {
		
		String result = "";
		
		String name = getPara("name");
		String stunum = getPara("stunum");
		String password  = getPara("pass");
		String phone = getPara("phone");
		String email = getPara("mail");
		String mac = getPara("mac");
		
			if(StudentInfo.dao.findStudent(mac)==null) {
				if(StudentInfo.dao.findStudentByStunum(stunum)==null) {
					StudentInfo studentInfo = new StudentInfo();
					studentInfo.setName(name);
					studentInfo.setEmail(email);
					studentInfo.setPhone(phone);
					studentInfo.setStunum(stunum);
					studentInfo.setPassword(password);
					studentInfo.setMac(mac);
					studentInfo.save();
					result = "恭喜大佬，注册成功了";
				}else {
					result = "你是不是注册过了，反正你的学号已经被鬼注册了";
				}
			}else {
				result = "该Mac已经被注册，如非本人操作请联系导生大大";
			}
		
		renderText(result);
		
	}

}
